package ClassDay1;

import ClassDay1.dao.impile.AppDao;
import ClassDay1.service.imple.AppService;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class App {
    public static  void main(String[] args){
        //普通状态下的对象创建,因为使用spring的情况下，普通打印状态会影响结果
        try {
            AppService r = new AppService();
            r.save();
        }catch (NullPointerException Exp){
            System.out.println(Exp);
        }
        //Ioc思想的创建
        //获取IOC容器(不使用new进行创建)
        ApplicationContext actx=new ClassPathXmlApplicationContext("BeanConfig.xml");
//        AppDao dao = (AppDao) actx.getBean("dao");
//        dao.save();
        AppService service = (AppService) actx.getBean("service");
        service.save();
        AppDao fa= (AppDao) actx.getBean("staticdaofactory");
        fa.save();
        AppDao newDao = (AppDao) actx.getBean("NewServiceFactory");
        newDao.save();
        TheMap theMap=actx.getBean("TheMap", TheMap.class);
        System.out.println(theMap);
    }

}
